using System.Collections.Generic;

/// <summary>
/// 对象池基础接口
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
public interface IPool<T>
{
    /// <summary>
    /// 获取对象
    /// </summary>
    T Get();
    
    /// <summary>
    /// 归还对象
    /// </summary>
    void Return(T obj);
    
    /// <summary>
    /// 获取池中对象数量
    /// </summary>
    int Count { get; }
    
    /// <summary>
    /// 获取活跃对象数量
    /// </summary>
    int ActiveCount { get; }
    
    /// <summary>
    /// 清理池
    /// </summary>
    void Clear();
}

/// <summary>
/// 可池化对象接口
/// </summary>
public interface IPoolable
{
    /// <summary>
    /// 对象从池中取出时调用
    /// </summary>
    void OnSpawn();
    
    /// <summary>
    /// 对象归还到池中时调用
    /// </summary>
    void OnDespawn();
}

/// <summary>
/// 对象池工厂接口
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
public interface IPoolFactory<T>
{
    /// <summary>
    /// 创建新对象
    /// </summary>
    T Create();
    
    /// <summary>
    /// 销毁对象
    /// </summary>
    void Destroy(T obj);
    
    /// <summary>
    /// 重置对象状态
    /// </summary>
    void Reset(T obj);
}
